package cn.yhp.mybatis.session.defaults;

import cn.yhp.mybatis.binding.MapperRegistry;
import cn.yhp.mybatis.session.SqlSession;

/**
 * @author yhp
 * @description 默认SqlSession实现类
 * @date 2023/11/8
 */
public class DefaultSqlSession implements SqlSession {

    /**
     * 映射器注册机
     */
    private MapperRegistry mapperRegistry;

    public DefaultSqlSession(MapperRegistry mapperRegistry){
        this.mapperRegistry=mapperRegistry;
    }

    @Override
    public <T> T selectOne(String statement) {
        return (T)("你被代理了："+statement);
    }

    @Override
    public <T> T selectOne(String statement, Object parameter) {
        return (T)("你被代理了,方法："+statement+",入参："+parameter);
    }

    @Override
    public <T> T getMapper(Class<T> type) {
        return mapperRegistry.getMapper(type,this);
    }

}
